package cst.a228htt.widgettest228htt;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    private EditText inputtext;
    private Button textbutton;

    private void init(){
        inputtext=(EditText)findViewById(R.id.inputtext);
        textbutton=(Button)findViewById(R.id.textbutton);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
        textbutton.setOnClickListener(this);//监听
    }

    @Override
    public void onClick(View v){
        switch (v.getId()){
            case R.id.textbutton:
                Toast.makeText(this, "内容是"+inputtext.getText().toString(), Toast.LENGTH_SHORT).show();
                break;
        }
    }
}
